package com.example.android_practice.lifeCycle;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.Lifecycle;

import com.example.android_practice.R;
import com.yaoyanshe.trialfield.common.base.BaseActivity;

/**
 * Created by tangcan on 20/9/26.
 * 修改人：tangcan
 * 修改时间：20/9/26 上午10:05
 * 修改备注：
 */
public class LifeCycleActivity extends BaseActivity {
    @Override
    protected int getLayoutId() {
        return R.layout.jetpack_lifecycle;
    }

    private MyLocationListener myLocationListener;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        myLocationListener=new MyLocationListener(this, new MyLocationListener.OnLocationChangeListener() {
            @Override
            public void onChanged(double latitude, double longitude) {
                //展示收到的位置信息
            }
        });

        //将观察者与被观察者绑定
        getLifecycle().addObserver(myLocationListener);
    }


}
